package m2_work;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.ConnectionFactory;

import java.util.Scanner;

public class Producer {
    public static void main(String[] args) throws Exception {
        ConnectionFactory f=new ConnectionFactory();
        f.setHost("192.168.64.140");
        f.setPort(5672);
        f.setUsername("admin");
        f.setPassword("admin");

        Channel c = f.newConnection().createChannel();
        //定义队列      //1.名称        //2.是否为持久队列   //3.是否独占（只能有一个消费者）  //4.自动删除     //5.其他属性是设置
        c.queueDeclare("helloworld",false,false,false,null);
        while (true){
            System.out.println("输入消息：  ");
            String msg=new Scanner(System.in).nextLine();
                    //1.m3模式
            c.basicPublish("","helloworld",null,msg.getBytes());
        }
        //
    }
}
